﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using DatabasePluginInterface;
using QLNhaThuoc.DAL;
using QLNhaThuoc.BL;
using QLNhaThuoc.DTO;

namespace QLNhaThuoc
{
    public partial class Form_QLNT : Form
    {
        public Form_QLNT()
        {
            InitializeComponent();
        }

        private void Form_QLNT_Load(object sender, EventArgs e)
        {
            DataProvider.ConnectionString = "Provider=SQLOLEDB.1;Data Source=.;Integrated Security=SSPI;Initial Catalog=QLNhaThuoc";

            danhMụcToolStripMenuItem.Enabled = false;
            quảnTrịToolStripMenuItem.Enabled = false;

            ShowFormDangNhap();
        }

        private void côngTyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_DMCongTy frm = new Form_DMCongTy();
            frm.MdiParent = this;
            frm.Show();
        }

        private void thuốcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_Thuoc frm = new Form_Thuoc();
            frm.MdiParent = this;
            frm.Show();
        }

        private void loạiThuốcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_DMLoaiThuoc frm = new Form_DMLoaiThuoc();
            frm.MdiParent = this;
            frm.Show();
        }

        private void nhânViênToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_NhanVien frm = new Form_NhanVien();
            frm.MdiParent = this;
            frm.Show();
        }

        private void hóaĐơnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_DMHoaDon frm = new Form_DMHoaDon();
            frm.MdiParent = this;
            frm.Show();
        }

        private void phiếuNhậpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_DMPhieuNhap frm = new Form_DMPhieuNhap();
            frm.MdiParent = this;
            frm.Show();
        }

        private void phiếuXuấtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_DMPhieuXuat frm = new Form_DMPhieuXuat();
            frm.MdiParent = this;
            frm.Show();
        }

        private void ngườiDùngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_NguoiDung frm = new Form_NguoiDung();
            frm.MdiParent = this;
            frm.Show();
        }

        private void đăngNhậpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_DangNhap frm = new Form_DangNhap();
            frm.MdiParent = this;
            frm.Show();
        }

        private void ShowFormDangNhap()
        {
            Form_DangNhap frm = new Form_DangNhap();
            frm.MdiParent = this;
            frm.Show();
        }

        private void đăngXuấtToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DangXuat();
        }

        private void đăngXuấtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DangXuat();
        }

        private void DangXuat()
        {
            danhMụcToolStripMenuItem.Enabled = false;
            quảnTrịToolStripMenuItem.Enabled = false;
        }

        private void thoátToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void giúpĐỡToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\..\\..\\help.docx");
        }

        private void configToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_Config frm = new Form_Config();
            //frm.MdiParent = this;
            frm.ShowDialog();
            string connectionString = frm.GetConnectionString();
            if(!string.IsNullOrEmpty(connectionString))
            {
                DataProvider.ConnectionString = connectionString;
            }
        }

        private void importDữLiệuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            From_Mapping frm = new From_Mapping();
            frm.MdiParent = this;
            frm.Show();
        }
    }
}
